<section class="content-header">
  <ol class="breadcrumb">
    <li><a href="/luckydog/index"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li>账号管理</li>
    <li class="active">角色列表</li>
  </ol>
</section>
<section class="content">
      <div class="row">
        <div class="col-md-12">
          <div class="box">
            
            <div class="box-header with-border">
            <a href="/role/add"><button type="button" class="btn bg-block margin" style="width: 100px;">添加角色</button></a>
            </div>
            
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-striped table-bordered table-hover">
                <tr>
                    <th>序号</th>
                    <th>角色</th>
                    <th width="30%">权限清单</th>
                    <th>添加时间</th>
                    <th>操作</th>
                </tr>
                <?php if(!empty($roleList)):?>
                <?php foreach($roleList as $key=> $row):?>
                    <tr class="gradeX">
                        <td class="center"><?php echo $row['id'];?></td>
                        <td class="center itemDetail" ><?php echo $row['name'];?></td>
                        <td class="center"><?php echo implode("、", $row['rolePower'])?></td>
                        <td class="center" ><?php echo  date("Y-m-d h:i:s",$row['addtime'])?></td>
                        <td class="center " data_id = "<?php echo $row['id'];?>">
                            
                            <a href="/role/add?gropuID=<?php echo $row['id']?>" class="edit_role">设置</a>
                            <?php endif;?>
                            <?php if(check_authorize("System","Role","delete")):?>
                            &nbsp;|&nbsp;<a href="javascript:;" class="J_del">删除</a>
                            <?php endif;?>
                        </td>
                    </tr>
            	<?php endforeach;?>
            	<?php endif;?>
              </table>
            </div>
          </div>
        </div>
    </div>
</section>
<script>
    $(document).ready(function() {
        $(".J_del").click(function(){
            var id = $(this).parent().attr("data_id");
            if (confirm("您确定要删除该角色吗？")) {
                $.post("/role/delete", {"id":id}, function(data) {
                    layer.msg(data.message);
                    if(data.code == 1)
                    {
                        window.location.reload();
                    }
                        
                },"json");
            }
        })
    });
</script>
